<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php echo $this->Html->charset(); ?>
	<title>
		<?php __('Socialite'); ?>
		<?php echo $title_for_layout; ?>
	</title>
	<?php
		echo $this->Html->meta('icon');

		echo $this->Html->css('cake.generic');
        echo $this->Html->css('main');
		echo $scripts_for_layout;
	?>
</head>
<body>
    <div id="header">
        <div id="logo">
            <?php 
                echo $this->Html->link(
                    $this->Html->image('logo.png', array('alt'=> __('Socialite Event Management', true), 'border' => '0')),
                    '/',
                    array('target' => '_parent', 'escape' => false)
                );
            ?>
        </div>

        <div id="slogan">
            <p> let's have some fun tonight! </p>
        </div>

        <div id="logout">
            <?php
             $controller = $this->Session->read('account_type');
              if ($controller){
                  $controller = $controller.'s';
                  echo '<li>'. $this->Html->link('Logout', array('controller' => $controller, 'action' => 'logout')). '</li>';
              }
            ?>
        </div>
    </div>
	<div id="container">
		<div id="content">
            <?php echo $this->Session->flash(); ?>
            <br/>
            <?php
            //check account type
            $account_type = $this->Session->read('account_type');
            if ($account_type) {
                switch ($account_type) {
                    case 'user':
                        $user = $this->Session->read('user');
                        if ($user) {
                            echo '<div id="sidebar-holder">';
                            echo '<div id="profile">';
                            echo '<div id="profile_pic">';
                            if (file_exists('img/profile/user/'.$user['User']['id'].'.jpg')) {
                                echo $this->Html->image('profile/user/' . $user['User']['id'] . '.jpg',array('width'=>'235'));
                            } else {
                                echo $this->Html->image('default_user.jpg',array('width'=>'235'));
                            }                                          

                            echo '<h3 id="profile-name">';
                            echo $user['User']['first_name'] . ' ' . $user['User']['last_name'];
                            echo '</h3>';
                            echo '</div>';
                            echo '</div>';
                            echo '<div id="sidebar">';
                            echo '<h2>Actions</h2>';
                            echo '<div class="actions">';
                            echo '<ul>';
                            echo '<li>' . $this->Html->link(__('Events Home', true), array('controller' => 'events', 'action' => 'index')) . '</li>';
                            echo '<li>' . $this->Html->link(__('Edit my profile', true), array('controller' => 'users', 'action' => 'edit_profile')) . '</li>';                            
                            echo '</ul>';
                            echo '</div>';
                            echo '</div>';
                            echo '</div>';
                        }
                        break;
                    case 'host':
                        $host = $this->Session->read('host');
                        if ($host) {
                            echo '<div id="sidebar-holder">';
                            echo '<div id="profile">';
                            echo '<div id="profile_pic">';

                            if (file_exists('img/profile/host/'.$host['Host']['id'].'.jpg')) {
                                echo $this->Html->image('profile/host/' . $host['Host']['id'] . '.jpg',array('width'=>'235'));
                            } else {
                                echo $this->Html->image('default_host.jpg',array('width'=>'235'));
                            }

                            echo '<h3 id="profile-name">';
                            echo $host['Host']['business_name'];
                            echo '</h3>';
                            echo '</div>';
                            echo '</div>';
                            echo '<div id="sidebar">';
                            echo '<h2>Actions</h2>';
                            echo '<div class="actions">';
                            echo '<ul>';
                            echo '<li>' . $this->Html->link(__('Events Home', true), array('controller' => 'events', 'action' => 'index')) . '</li>';
                            echo '<li>' . $this->Html->link(__('Edit my profile', true), array('controller' => 'hosts', 'action' => 'edit_profile')) . '</li>';
                            echo '</ul>';
                            echo '</div>';
                            echo '</div>';
                            echo '</div>';
                        }
                        break;
                    default:
                        echo 'No information';
                        break;
                }
            }
            ?>
			<?php echo $content_for_layout; ?>
        </div>

		<div id="footer">
			<?php echo $this->Html->link(
					$this->Html->image('cake.power.gif', array('alt'=> __('Dasdak: the rapid development php framework', true), 'border' => '0')),
					'http://www.cakephp.org/',
					array('target' => '_blank', 'escape' => false)
				);
			?>
		</div>

    </div>
	<?php
        echo $this->element('sql_dump');
    ?>
</body>
</html>